<link rel="stylesheet" href="/upload/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="/upload/kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="/upload/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="/upload/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="/upload/kindeditor/plugins/code/prettify.js"></script>
        <script type="text/javascript" src="<?php echo $this->module->assetsUrl; ?>/datepicker/WdatePicker.js" /></script>

        <script charset="utf-8" src="<?php echo $this->module->assetsUrl; ?>/js/jquery.Jcrop.js"></script>
        <link rel="stylesheet" href="<?php echo $this->module->assetsUrl; ?>/css/jquery.Jcrop.css" />



<script >
            
    
            KindEditor.ready(function(K) {
                
            editor = K.create('#ActivityLinkSignup_content', {
            allowPreviewEmoticons: false,
            allowImageUpload: true,
            allowFileManager: true,
           // fileManagerJson : 'kindeditor/php/file_manager_json.jsp',
            resizeType : 1,
            items : [
           'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about']
            });

            });
</script>
  
<script >

	var url_host = "http://<?php echo Yii::app()->params['HTTP_HOST']; ?>";

function uploadImag(Nid,thumb){
             
             KindEditor.ready(function(K) {
        var editor = K.editor({
            allowPreviewEmoticons: false,
            allowImageUpload: true,
            allowFileManager: false,
            urlType: 'domain'
         
            
        });
        
       // var ImgThumbUrl = K('#'+thumb).attr('src');
       // if(!ImgThumbUrl){//没上传文件
             //console.log(K('#'+thumb).attr('src'));
               editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    fileUrl: K('#'+Nid).val(),
                    imageUrl : K('#'+Nid).val(),
                    clickFn: function(url, title) {
                        // var file_url_img = "http://m.kxiche.com";
                        //var file_url_img = "http://localhost:8087";
                       // if (url.indexOf("http") > -1) {
                            K('#'+Nid).val(url_host + url);
                            K('#'+thumb).attr('src', url_host + url);
                          
                           // console.log($('#Activety_banner_url').val());
                           // K('.jcrop-tracker img').attr('src', url_host + url);
                            K('#jiancai_a_url').attr('src', url_host + url);
                            K('#input_img_url_url').val(url_host + url);
                            K('#'+Nid).attr('type', 'text');
                            
                            
                             if(!K('#btn_cut').text()){
                                  
                                    K('#'+thumb).after('<button  id="btn_cut" type="button" data-toggle="modal" data-target="#myModal_crop_url" >裁剪</button>');
                             }
                            K('#img_type').val(thumb);
                            editor.hideDialog();

                            jiancai_url(thumb);//jcrop初始化
                    }
                });
            });
        
//        }else{
//            alert('已有图片请先删除!');
//            
//            if(!K('#btn_del_cut').text()){
//                 K('#'+thumb).after('<button  id="btn_del_cut" type="button" onclick="del_cut('+ImgThumbUrl+')" >删除</button>');
//            }
//           
//            return false;
//        }
        
      });
            
  }
  
  
  function del_cut(){
      
      console.log('1111111111');
  }

</script>




<style type="text/css">
    
div.form label.labelForRadio 
{
    display:inline-block;
    width:auto;float:none;
}
</style>
 
 

<div class="container-fluid">

    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">
                活动管理 <small>修改</small>
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="edit">活动管理</a> 
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">修改</a></li>

            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
    
    
    
     <div class="control-group">             
        <div class="controls">
            <?php 
                    if(Yii::app()->user->hasFlash('addform')){
                             $flash = Yii::app()->user->getFlash('addform');                           
                            echo ' <div class="alert alert-info">'.$flash.'</div>';  
                           
                            echo '<button  type="button"   onclick="history.go(-2)"  class="btn blue" >返回活动列表</button>';
                    }
                    else{
                            echo '<button  type="button"   onclick="history.go(-1)"  class="btn blue" >返回活动列表</button>';
                    }
            
            
           ?>   
        </div>
     </div>
    
     
                        <div class="row-fluid">
                            <div class="span12">
                                <!-- BEGIN SAMPLE FORM PORTLET-->  


                                <div class="portlet box blue tabbable">
                                    <div class="portlet-title">
                                        <div class="caption">
                                            <i class="icon-reorder"></i>
                                            <span class="hidden-480">活动选择</span>
                                        </div>
                                    </div>
                                    <div class="portlet-body form">
                                        <div class="tabbable portlet-tabs">
                                            <ul class="nav nav-tabs">

                                                <?php  switch ($Activity->type_id) {

                                                          case '101':
                                                                echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li>';
                                                          break;
                                                          case '102':
                                                               echo  '<li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                                          break;

                                                          default:
                                                              echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li><li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                                          break;
                                                         } 
                                                 ?>

                                            </ul>
                                            <div class="tab-content">


                                                <div class="tab-pane active"  id="portlet_tab1">
                                                    <!-- BEGIN FORM-->
                        <!--                            <form action="add" class="form-horizontal" method="post">-->

                                                        <?php
                                                        $form = $this->beginWidget(
                                                                'CActiveForm', array(
                                                            'id' => 'active-form',
                                                          // 'enableAjaxValidation'=>true,   
                                                           'enableClientValidation'=>true,
                                                            'clientOptions' => array(
                                                                'validateOnSubmit' => true,
                                                            ),
                                                            'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                                                // 'action'=>array('/admin'),
                                                        ));
                                                    ?>	
                                                       
                                                        <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="101" class="m-wrap small" />
                                                        <div class="control-group">
                                                            <label class="control-label">是否热点</label>
                                                            <div class="controls">
                                                                <?php
                                                                echo $form->radioButtonList($Activity, 'is_hot', array(1 => '是', 2 => '否'), array(
                                                                    'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                                                    'labelOptions' => array('class' => 'labelForRadio'),
                                                                    'style' => 'margin-left:0',
                                                                ));
                                                                ?>
                                                            </div>
                                                         </div>  
                                                        
                                                        
                                                        
                                                        <div class="control-group">
                                                            <label class="control-label">活动类型</label>
                                                            <div class="controls">
                                                                  <?php echo $form->dropDownList($Activity,'cat_id',Type::model()->getCategoryList()); ?>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="control-group">
                                                            <label class="control-label">标题</label>
                                                            <div class="controls">

                                                                <?php echo $form->textField($Activity,'title',array('class'=>'m-wrap large','placeholder'=>"标题"))?>
                                                                <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label">活动时间</label>
                                                            <div class="controls">

                                                                <?php echo $form->textField($Activity,'start_time',array('class'=>'m-wrap medium','placeholder'=>"开始时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>
                                                                <?php echo $form->textField($Activity,'end_time',array('class'=>'m-wrap medium','placeholder'=>"结束时间",'onclick' => "WdatePickerSet($('#Activity_start_time').val())"))?>
                                                                <?php echo $form->error($Activity, 'start_time', array('class' => 'label label-danger')); ?>
                                                                <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="control-group" >
                                                            <label class="control-label">活动背景图片</label>
                                                            <div class="controls">
                                                                <div class="fileupload fileupload-new" data-provides="fileupload">
                                                                    <img id="file_upload_ws" src="<?php echo $Activity->banner_url;?>" width="150" height="85" />
                                                                    <input type="hidden" name='Activity[banner_url]' id="Activety_banner_url">
                                                                    <input type="button"  id="Activity-btn-upload"  onclick="uploadImag('Activety_banner_url','file_upload_ws')" value='点击上传' />      
                                                                </div> 
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label">活动背景缩略图片</label>
                                                            <div class="controls">
                                                                <div class="fileupload fileupload-new" data-provides="fileupload">
                                                                    <img id="file_upload_ws_min" src="<?php echo $Activity->min_banner_url;?>" width="50" height="50" />
                                                                    <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_banner_url">
                                                                    <input type="button" onclick="uploadImag('Activety_min_banner_url','file_upload_ws_min')" value='点击上传' />      

                                                                </div> 
                                                            </div>
                                                        </div>
                           

                                                        <div class="control-group">
                                                            <label class="control-label">是否签到</label>
                                                            <div class="controls">
                                                                      <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_checkin',
                                                                                array(1=> '是',2=>'否'), 
                                                                                array(
                                                                                    'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                                                    'labelOptions'=>array('class'=>'labelForRadio'),
                                                                                    'style'=>'margin-left:0',
                                                                                    'disabled '=>'disabled'
                                                                                    ));
                                                                      ?>
                                                            </div>
                                                        </div>
                                                        
                                                        
                                                        
                                                       <div class="control-group" id="checkintime" style="display:none;" >
                                                        <label class="control-label">签到时间</label>
                                                        <div class="controls">
                                                            <input type="text"  id="ActivityLinkSignup_checkin_start_time" value="<?php echo $ActivityLinkSignup->checkin_start_time ?>" placeholder="开始时间" name="ActivityLinkSignup[checkin_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                                            <input type="text" id="ActivityLinkSignup_checkin_end_time" value="<?php echo $ActivityLinkSignup->checkin_end_time ?>" placeholder="结束时间" name="ActivityLinkSignup[checkin_end_time]" class="m-wrap medium" onclick="WdatePickerSet($('#ActivityLinkSignup_lottery_start_time').val())" />

                                                        </div>
                                                         </div>


                                                        <div class="control-group">
                                                            <label class="control-label">是否抽奖</label>
                                                            <div class="controls">
                                                                    <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_lottery',
                                                                                array(1=> '是',2=>'否'), 
                                                                                array(
                                                                                    'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                                                    'labelOptions'=>array('class'=>'labelForRadio'),
                                                                                    'style'=>'margin-left:0',
                                                                                     'disabled '=>'disabled'
                                                                                    ));
                                                                    ?>

                                                            </div>
                                                        </div>

                                                       

                                                        <div class="control-group">
                                                            <label class="control-label">是否报名</label>
                                                            <div class="controls">
                                                                     <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_signup',
                                                                                array(1=> '是',2=>'否'), 
                                                                                array(
                                                                                    'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                                                    'labelOptions'=>array('class'=>'labelForRadio'),
                                                                                    'style'=>'margin-left:0',
                                                                                     'disabled '=>'disabled'
                                                                                    ));
                                                                    ?>
                                                            </div>
                                                        </div>



                                                        <div class="control-group" id="signuptime" style="display:none;" >
                                                            <label class="control-label">报名时间</label>
                                                            <div class="controls">
                                                                <input type="text" disabled id="ActivityLinkSignup_signup_start_time" value="<?php  echo date('Y-m-d H:i:s',$ActivityLinkSignup->signup_start_time);?>" placeholder="开始时间" name="ActivityLinkSignup[signup_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                                                <input type="text" disabled id="ActivityLinkSignup_signup_end_time" value="<?php  echo date('Y-m-d H:i:s',$ActivityLinkSignup->signup_end_time);?>" placeholder="结束时间" name="ActivityLinkSignup[signup_end_time]" class="m-wrap medium" onclick="WdatePickerSet($('#ActivityLinkSignup_signup_start_time').val())" />

                                                            </div>
                                                        </div>

                                                        <div class="control-group">

                                                            <label class="control-label">联系人</label>
                                                            <div class="controls">

                                                                 <?php echo $form->textField($ActivityLinkSignup,'contacts',array('class'=>'m-wrap medium'))?>
                                                                <?php echo $form->error($ActivityLinkSignup, 'contacts', array('class' => 'label label-danger')); ?>
                                                            </div>
                                                        </div>
                                                        <div class="control-group">

                                                            <label class="control-label">联系电话</label>
                                                            <div class="controls">

                                                                  <?php echo $form->textField($ActivityLinkSignup,'tel',array('class'=>'m-wrap medium'))?>
                                                                <?php echo $form->error($ActivityLinkSignup, 'tel', array('class' => 'label label-danger')); ?>
                                                            </div>
                                                        </div>


                                                        <div class="control-group">
                                                            <label class="control-label">活动地址</label>
                                                            <div class="controls">

                                                                <?php echo $form->textField($ActivityLinkSignup,'address',array('class'=>'m-wrap span8'))?>
                                                                <?php echo $form->error($ActivityLinkSignup, 'address', array('class' => 'label label-danger')); ?>
                                                             </div>
                                                        </div>


                                                        <div class="control-group">
                                                            <label class="control-label">内容</label>
                                                            <div class="controls">

                                                              <?php echo $form->textArea($ActivityLinkSignup,'content',array('class'=>'m-wrap','style'=>'width:800px; height:400px;'))?>
                                                            </div>
                                                        </div>



                                                        <div class="form-actions ">
                        <!--                                    <button type="submit" class="btn blue"><i class="icon-ok"></i> 添加活动</button>-->

                                                            <button type="submit"  class="btn blue"><i class="icon-ok"></i>修改活动</button>
                                                            <button type="button" class="btn">重填</button>
                                                        </div>
                                                    <?php $this->endWidget(); ?>


                                                    <!-- END FORM-->  
                                                </div>

                                                <div class="tab-pane " id="portlet_tab2">
                                                     <?php
                                                        $form = $this->beginWidget(
                                                                'CActiveForm', array(
                                                            'id' => 'vote-form',
                                                          // 'enableAjaxValidation'=>true,   
                                                           'enableClientValidation'=>true,
                                                            'clientOptions' => array(
                                                                'validateOnSubmit' => true,
                                                            ),
                                                            'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                                                // 'action'=>array('/admin'),
                                                        ));
                                                    ?>	
                                                    <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="102" class="m-wrap small" />
                                                    
                                                    <div class="control-group">
                                                        <label class="control-label">是否热点</label>
                                                        <div class="controls">
                                                            <?php
                                                            echo $form->radioButtonList($Activity, 'is_hot', array(1 => '是', 2 => '否'), array(
                                                                'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                                                'labelOptions' => array('class' => 'labelForRadio'),
                                                                'style' => 'margin-left:0',
                                                            ));
                                                            ?>
                                                        </div>
                                                    </div>
                                                    
                                                        <div class="control-group">
                                                            <label class="control-label">活动类型</label>
                                                            <div class="controls">
                                                                  <?php echo $form->dropDownList($Activity,'cat_id',Type::model()->getCategoryList()); ?>
                                                            </div>
                                                        </div>
                                                    
                                                    <div class="control-group" >
                                                             <label class="control-label">标题</label>
                                                            <div class="controls">

                                                                <?php echo $form->textField($Activity,'title',array('class'=>'m-wrap large','placeholder'=>"标题"))?>
                                                                <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                                            </div>
                                                     </div>

                                                     <div class="control-group">
                                                            <label class="control-label">投票结束时间</label>
                                                            <div class="controls">

                                                                <?php echo $form->textField($Activity,'start_time',array('id'=>'Activity_start_time_vote','class'=>'m-wrap medium','placeholder'=>"开始时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>
                                                                <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                                            </div>
                                                      </div>

                                                     <div class="control-group">
                                                            <label class="control-label">展示结束时间</label>
                                                            <div class="controls">
                                                                <?php echo $form->textField($Activity,'end_time',array('class'=>'m-wrap medium','placeholder'=>"结束时间",'onclick' => "WdatePickerSet($('#Activity_start_time_vote').val())"))?>
                                                                <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                                            </div>
                                                      </div>
                                                      <div class="control-group">
                                                        <label class="control-label">活动背景图片</label>
                                                        <div class="controls">
                                                            <div class="fileupload fileupload-new" data-provides="fileupload">

                                                                <img id="file_upload_ws_vote" src="<?php echo $Activity->banner_url;?>" width="150" height="85" />
                                                                <input type="hidden" name='Activity[banner_url]' id="Activety_banner_url_vote">
                                                                <input type="button"  id="Activity-btn-upload"  onclick="uploadImag('Activety_banner_url_vote','file_upload_ws_vote')" value='点击上传' />      

                                                            </div> 
                                                        </div>
                                                    </div>

                                                    <div class="control-group">
                                                        <label class="control-label">活动背景缩略图片</label>
                                                        <div class="controls">
                                                            <div class="fileupload fileupload-new" data-provides="fileupload">
                                                                <img id="file_upload_ws_min_vote" src="<?php echo $Activity->min_banner_url;?>" width="50" height="50" />
                                                                <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_banner_url_vote">
                                                                <input type="button" onclick="uploadImag('Activety_min_banner_url_vote','file_upload_ws_min_vote')" value='点击上传' />      
                                                            </div> 
                                                        </div>
                                                    </div>
                                                        
                                                    

                                                      <div class="control-group col-md-offset-10">

                                                            <div class="controls">

                                                                <a class="btn red" data-toggle="modal" href="#add_vote">添加投票问题</a>
                                                            </div>
                                                      </div>


                        <!--                            <input type="text" class="m-wrap small" id="input_option"><button class="addoption" id="add_option">增加选项单选</button>-->
                                                   <div class="portlet box yellow">
                                                        <div class="portlet-title">
                                                                <div class="caption"><i class="icon-coffee"></i>投票问题</div>
                                                                <div class="tools">

                        <!--                                            <button href="javascript:;" class="add"  onclick="add_question()">添加</button>-->

                                                                        <a href="javascript:;" class="remove"></a>

                                                                </div>
                                                        </div>
                                                        <div class="portlet-body">
                                                            <table class="table table-bordered table-hover">
                                                                    <thead>
                                                                            <tr>
                                                                                    <th>问题</th>
                                                                                    <th>选项</th>

                                                                            </tr>
                                                                    </thead>
                                                                    <tbody id="tbody_vote">
                                                                             <?php  
                                                                             //p_e($ActivityLinkVoteQ);


                                                                                   $ActivityQNum = count($ActivityLinkVoteQ);
                                                                                   $xuanxiang='';
                                                                                    foreach ($ActivityLinkVoteQ as $k=>$v){
                                                                                        $ActivityLinkVoteA = ActivityLinkVoteA::model()->findAllByAttributes(array('vote_q_id' => $v['id'])); 

                                                                                        if($ActivityLinkVoteA){

                                                                                             foreach($ActivityLinkVoteA as $kk=>$vv){

                                                                                                   // $xuanxiang .= '<span>{'.$vv['sort'].'.'.$vv['a_content']. '} </span> ';
                                                                                                 $xuanxiang .= '<span>{'.$vv['a_content']. '} </span> ';
                                                                                            }
                                                                                        }

                                                                                             echo '<tr><td><span>'.$v['sort'].'.'.$v['q_content'].'</span></td><td>'.$xuanxiang.'</td></tr>';

                                                                                        $xuanxiang='';
                                                                                    }


                                                                             ?>
                                                                    </tbody>
                                                            </table>





                                                        </div>
                                                </div>


                                                     <div class="form-actions">
                                                         <button type="submit"  id="submit_vote" class="btn blue"><i class="icon-ok"></i>修改活动</button>
                                                            <button type="reset" class="btn" >重填</button>
                                                      </div>

                                                    <?php $this->endWidget(); ?>	

                                                </div>


                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- END SAMPLE FORM PORTLET-->
                            </div>
                        </div>
<!-- END PAGE CONTENT--> 

      
    
    
    
</div>







<div id="add_vote" class="modal hide fade" tabindex="-1" data-width="560">
                <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h3>发起投票</h3>
                </div>
                <div class="modal-body">
                        <div class="row-fluid">
                                <div class="span6">
                                       <input type="text" placeholder="请填写问题" id="question" class="span12 m-wrap">
                                                  
                                            <label class="radio">
                                                <input type="radio" id="ActivityLinkVoteQ_type_id_tmp"   checked="checked" value="31" />单选
                                            </label>
                                      <div class="controls" id="answer_input_div"> 
                                         
                                            <input type="text" id="answer<?php echo $ActivityQNum; ?>" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][0]" class="span12 m-wrap">
                                            <input type="text" id="answer<?php echo $ActivityQNum+1; ?>" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][1]" class="span12 m-wrap">
                                       
                                            <a class="blue small" id="a_add_vote" onclick="add_vote(this)">[+添加选项]</a>
                                            <a class="blue small" id="a_add_vote" onclick="del_vote(this)">[-删除选项]</a>
                                      </div>
                                </div>
                        </div>
                </div>
                <div class="modal-footer">
                        <button type="button small" id="add_vote_ok"  class="btn blue">保存</button>
                           <button type="button small" data-dismiss="modal"  onclick="colse('#add_vote')" class="btn">退出</button>
                </div>
</div>
 

<div class="modal fade in" id="myModal_crop_url" tabindex="-1" style="width:auto; margin: -10px 0 0 -350px; max-width:1200px;display:none;" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
               <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">图片剪裁</h4>
                  </div>
                   <div class="modal-body" style="max-height:400px; ">
                       <div class="row-fluid">
                           <div class="span6">
                                <div id="jiancai_a_url_remove">
                                    <img  id="jiancai_a_url" >
                                </div>
                            </div>
                            <input type="hidden" id="x_url" name="x_url" />
                                <input type="hidden" id="y_url" name="y_url" />
                                <input type="hidden" id="w_url" name="w_url" />
                                <input type="hidden" id="h_url" name="h_url" />
                                <input type="hidden" id="input_img_url_url" name="input_img_url_url" />
                                <input type="hidden" id="img_type" name="img_type" />
                      </div>
                        
                    </div>
                    <div class="modal-footer">
                      <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                      <button type="button" class="btn btn-primary" onclick="img_sub_url()">保存</button>
                    </div>
                </div>
              </div>
            </div>


<script type="text/javascript">
   
   function colse(divid){
  //var a=$('#table-user-prepaid_c0_0').val();
    $(divid).modal('hide');
}
$(document).ready(function() {    

       
          if($('#ActivityLinkSignup_is_need_checkin_0').attr('checked')){
        
                         $("#checkintime").attr("style", "display:bolck");
            }
       
   });
   
   
    $('#ActivityLinkSignup_is_need_signup_0').click(function(){
       
        if($(this).val()==1){
            $("#signuptime").attr("style","display:bolck");
            
        }
    });
    
    $('#ActivityLinkSignup_is_need_signup_1').click(function(){
      
        if($(this).val()==2){
            $("#signuptime").attr("style","display:none");
            
        }
    });
    
    
 
    
   //签到
    $('#ActivityLinkSignup_is_need_checkin_0').click(function() {

        if ($(this).val() == 1) {
            $("#checkintime").attr("style", "display:bolck");

        }
    });

    $('#ActivityLinkSignup_is_need_checkin_1').click(function() {

        if ($(this).val() == 2) {
            $("#checkintime").attr("style", "display:none");

        }
    });
    
    
    
     
     var a_i =3;//答案数组下标
     var a_j= 3;////答案id
     var a_q= <?php echo isset($ActivityQNum)?$ActivityQNum:0;?>;//提交问题数组下标
     var a_a= 1;//提交答案 数组下标
     var isNum =a_q;
     
     
    function add_vote(obj) {
      var htmloptions ='';
        htmloptions += '<input type="text" id="answer'+a_j+'" placeholder="请填写答案" name="ActivityLink[answer]['+a_i+']" class="span12 m-wrap">';
       $("#answer_input_div input[type='text']:last").after(htmloptions); 

        a_j = a_j+1;
        a_i = a_i+1;
    }
    
     function del_vote(obj){
        
        if(a_j >2 && a_i>2){
            $("#answer_input_div input[type='text']:last").remove();   
            a_j = a_j-1;
            a_i = a_i-1;
        }
    }
    
    
                                   
    $('#add_vote_ok').click(function(){
     
       a_q = a_q+1;

       console.log("a_q:"+a_q);
        var htmlanswer ='';
       $("#answer_input_div input").each(function(){
           htmlanswer +=''+a_a+'.<input type="text" style="width:100px;" name="ActivityLinkVoteA[a_content]['+a_q+']['+a_a+']" value="'+$(this).val()+'" />  ';
           a_a =a_a+1;
       });
       a_a=1;
       
        var qhtml = $("#question").val(); 
        var q_type_id=$("#ActivityLinkVoteQ_type_id_tmp").val();
        var htmloptions ='';
        htmloptions += '<tr><td><span id=q>'+a_q+'</span><input type="text"  name="ActivityLinkVoteQ[q_content]['+a_q+']" value="'+qhtml+'"><a  onclick="deleteEditCurrentRow(this);">删除问题</a></td><td id=a>'+htmlanswer+'</td><input type="hidden"  name ="ActivityLinkVoteQ[type_id]" value="'+q_type_id+'" ></tr>';
         //a_q =a_q+1;
        $('#tbody_vote').append(htmloptions); 
        $("#question").val('');
        
    });
    
  
    
   function deleteEditCurrentRow(obj,id){
       
       if(a_q >1 ){
          
           // a_a = a_a-1;
            if(a_q >isNum)
                a_q = a_q-1;
            console.log("a_q:"+a_q);
            var tr=obj.parentNode.parentNode;
            var tbody=tr.parentNode;
             
            tbody.removeChild(tr);
            
            
            $(tbody).each(function(i,item){   
                 $.each(item.rows,function(k,v){  //tr
                       $(v).find("#q").text((k+1));
                       $(v).find("span").next().attr('name','ActivityLinkVoteQ[q_content]['+(k+1)+']'); //问题
                       tmpnum=1;
                       $.each($(v).find("#a"),function(kk,vv){
                             $.each($(vv).find("input"),function(kkk,vvv){
                                   $(vvv).attr('name','ActivityLinkVoteA[a_content]['+(k+1)+']['+tmpnum+']');
                                   tmpnum = tmpnum+1;
                              });    
                       }); 
                     
                });  
            });
            
//            var V_D=$('#ActivityLinkVoteQ_del').val();
//            $('#ActivityLinkVoteQ_del').val(id+','+V_D);
            
        }else{
            alert("无法删除至少保留一个问题！");
            
        }
           
           
            
    }
    
    

    
    
   $(document).ready(function() {    
       
    var type_id = <?php echo $Activity->type_id?$Activity->type_id:0; ?>;
    console.log(type_id);
    
    
    
      switch(type_id)
      {
       
         case 101:
             
            if( $(':radio[name="ActivityLinkSignup[is_need_lottery]"]').eq(0).attr("checked"))
            {
                $("#lotterytime").attr("style","display:bolck");
            }

            if( $(':radio[name="ActivityLinkSignup[is_need_signup]"]').eq(0).attr("checked"))
            {
                $("#signuptime").attr("style","display:bolck");
            }
             
             
             $('#portlet_tab1').attr('class','tab-pane active');
             $('#portlet_tab1').attr('style','display:bolck');
             $('#portlet_tab2').removeAttr('class');
             $('#portlet_tab2').attr('style','display:none');
              $("#portlet_tab2").attr("disabled","disabled");
         break;
         
        case 102:
              
               $('#portlet_tab2').attr('class','tab-pane active');
               $('#portlet_tab2').attr('style','display:bolck');
               $('#portlet_tab1').removeAttr('class');
               $("#portlet_tab1").attr("style","display:none");
               $("#portlet_tab1").attr("disabled","disabled");
            break;
        default :
         
      }
       
       

   });
   
//   $('#add_active').click(function(e){
//        e.stopPropagation();
//         $('#active-form').submit();
//        
//   });
   

   
    function WdatePickerSet(val) {
        WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', minDate: val});
    }
    
    
     //裁剪为完成
   //店铺图片上传
    function img_sub_url()
    {
        var x = $('#x_url').val();
        var y = $('#y_url').val();
        var w = $('#w_url').val();
        var h = $('#h_url').val();
        var input_img_url = $('#input_img_url_url').val();
        //var input_img_id  = $('#input_img_id_url').val();
        var img_type = $('#img_type').val();
        //var hidden_update_info_url_img = $('#hidden_update_info_url_img_jian').val();
        if(x=='')
        {
            alert('请选择剪裁的区域');
            return false;
        }else
        {
            $.post(
                    '/xyhadm/activity/uploads',
                    {
                      'x':x,
                      'y':y,
                      'w':w,
                      'h':h,
                      'input_img_url':input_img_url,
                     // 'input_img_id':input_img_id,
                      'img_type':img_type
                      //'hidden_update_info_url_img':hidden_update_info_url_img
                    },
                    function(data){
                        
                        if(data){
                            alert('保存成功');
                            $('#myModal_crop_url').modal('hide');
                            
                            $('#'+img_type).removeAttr('src');
                            
                            $('#'+img_type).attr('src',data);
                           // $('#activity_img_cj').attr('style','display:bolck');
                             //parent.location.reload();
                        }
                        else if(data==3)
                        {
                            alert('系统繁忙请稍候在试');
                             $('#myModal_crop_url').modal('hide');
                        }
                                   
                    }
                    );
        }        
    }



   function updateCoords_url(c)
  {
    $('#x_url').val(c.x);
    $('#y_url').val(c.y);
    $('#w_url').val(c.w);
    $('#h_url').val(c.h);
  }

  
 
 function jiancai_url(thumb)
    {
        $('.jcrop-holder').remove(); 
        jcrop_api = $.Jcrop("#jiancai_a_url");
        jcrop_api.destroy();
        
        if(thumb == 'file_upload_ws' || thumb =='file_upload_ws_vote'){
                $('#jiancai_a_url').Jcrop({
                    aspectRatio: 750/445,
                    onChange: updateCoords_url
                  }); 
        }
            
        if(thumb == 'file_upload_ws_min' || thumb =='file_upload_ws_min_vote'){
                $('#jiancai_a_url').Jcrop({
                    aspectRatio: 1,
                    onChange: updateCoords_url
                  }); 
        }
    
        $('#myModal_crop_url').modal('show');
  } 
    
    
  
    

</script>

